package com.poxz.algorithm.luogu.p.p1036;
import java.io.*;
import java.util.*;

/**
 * 选数
 *
 * @author poxz
 */
public class Main {

    static IO IO = new IO();
    static int ans = 0;  
    static int count = 0;
    static int sum = 0;
    public static void main(String[] args) {
        int n = IO.nextInt();
        int k = IO.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = IO.nextInt();
        }
        dfs(a,0,k);
        IO.println(ans);
        IO.close();
    }
    // index 当前位置，count 当前选择的数量，sum 当前选择的和
    static void dfs(int[] a,int index, int k){
        if(count == k){
            if(isPrime(sum)){
                ans++;
            }
            return;
        }
        if(a.length - index < k - count){
            return;
        }

        count++;
        sum += a[index];
        dfs(a,index+1,k);
        count--;
        sum -= a[index];
        dfs(a,index+1,k);
    }

    static boolean isPrime(int n) {
        if(n < 2) {
            return false;
        }
        if(n == 2) {
            return true;
        }
        if(n % 2 == 0) {
            return false;
        }

        // 只检查奇数因子
        for(int i = 3; i * i <= n; i += 2) {
            if(n % i == 0) {
                return false;
            }
        }
        return true;
    }

    static class IO {
        BufferedReader br;
        StringTokenizer st;
        PrintWriter out;

        IO() {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        int[] nextIntArray(int n) {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

        long[] nextLongArray(int n) {
            long[] arr = new long[n];
            for (int i = 0; i < n; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }

        String[] nextStringArray(int n) {
            String[] arr = new String[n];
            for (int i = 0; i < n; i++) {
                arr[i] = next();
            }
            return arr;
        }

        void print(Object o) {
            out.print(o);
        }


        void println(Object o) {
            out.println(o);
        }

        void println() {
            out.println();
        }

        void printf(String format, Object... args) {
            out.printf(format, args);
        }

        void close() {
            out.flush();
            out.close();
        }
    }
}
